<?php

namespace App\Models\Tool;

use App\Models\BaseModel;
use App\Models\BaseToolAdmin;
use Encore\Admin\Traits\ModelTree;

class Share extends BaseToolAdmin
{
    use ModelTree;

    protected $fillable = ['title', 'pid', 'value', 'sort', 'type', 'remark', 'state', 'is_del', 'icon', 'is_free', 'points',];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->setParentColumn('pid');
        $this->setOrderColumn('sort');
    }

    public function children()
    {
        return $this->hasMany(static::class, $this->parentColumn)->where('is_del', 0)
            ->where('state', 1);
    }
}
